package com.umbrella.worker.web.controller.manager;

import java.util.Date;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import com.umbrella.worker.dto.CertificoreDO;
import com.umbrella.worker.dto.StaffDO;
import com.umbrella.worker.query.StaffQuery;
import com.umbrella.worker.query.StaffTimeQuery;
import com.umbrella.worker.query.SupplierQuery;
import com.umbrella.worker.result.JsonResultDO;
import com.umbrella.worker.result.JsonResultSupport;
import com.umbrella.worker.result.ResultDO;
import com.umbrella.worker.result.ResultSupport;
import com.umbrella.worker.service.ICertificoreService;
import com.umbrella.worker.service.IStaffService;
import com.umbrella.worker.service.ISuppliersService;
import com.umbrella.worker.util.PageBeanUtil;

@Controller
@RequestMapping(value = "/staff")
public class StaffController { 

	@Autowired
	public IStaffService staffService;
	
	@Autowired
	private ISuppliersService suppliersService;
	@Autowired
	private ICertificoreService certificoreService ;
	
	@RequestMapping(value = "/add.html", method = RequestMethod.GET)
	public ModelAndView add(ModelAndView mav, 
			HttpServletRequest request) {
		/*SupplierQuery query = new SupplierQuery();
		ResultDO result = suppliersService.list(query);
		if(result.isSuccess()) {
			mav.addObject("SUPPLIER_LIST", result.getModel(ResultSupport.FIRST_MODEL_KEY));
			mav.setViewName("manager2/staff/addStaff");
		} else {
			mav.setViewName("error");
		}
		mav.addObject("SUPPLIER_LIST", result.getModel(ResultSupport.FIRST_MODEL_KEY));*/
		mav.setViewName("manager2/staff/addStaff");
		return mav; 
	}
	
	@RequestMapping(value = "/addClear.html", method = RequestMethod.GET)
	public ModelAndView addClear(ModelAndView mav, 
			HttpServletRequest request) {
		SupplierQuery query = new SupplierQuery();
		ResultDO result = suppliersService.list(query);
		if(result.isSuccess()) {
			mav.addObject("SUPPLIER_LIST", result.getModel(ResultSupport.FIRST_MODEL_KEY));
			mav.setViewName("manager/staff/addClear");
		} else {
			mav.setViewName("error");
		}
		return mav; 
	}
	
	@RequestMapping(value = "/addMatron.html", method = RequestMethod.GET)
	public ModelAndView addMatron(ModelAndView mav, 
			HttpServletRequest request) {
		SupplierQuery query = new SupplierQuery();
		ResultDO result = suppliersService.list(query);
		if(result.isSuccess()) {
			mav.addObject("SUPPLIER_LIST", result.getModel(ResultSupport.FIRST_MODEL_KEY));
			mav.setViewName("manager/staff/addMatron");
		} else {
			mav.setViewName("error");
		}
		return mav; 
	}
	
	/**
	 * 添加家政人员
	 * @param mav
	 * @param staffDO
	 * @param request
	 * @return
	 */
	@RequestMapping(value = "/addStaff.html", method = RequestMethod.POST)
	public ModelAndView add(ModelAndView mav,
			StaffDO staffDO,
			HttpServletRequest request) {
		
		Integer supplierId = (Integer) request.getSession().getAttribute("MANAGER_SUPPLIER_ID");
		String author=(String) request.getSession().getAttribute("MANAGER_NAME");
		if(author==null || author.equals("")){
			author="nothing";
		}
		if(supplierId==null){
			supplierId=1;
		}
		
		staffDO.setCreateAuthor(author);
		staffDO.setModifiAuthor(author);
		staffDO.setwSSupplierId(supplierId);
		
		//上传图片头像保存的ID
		
		
		ResultDO result = staffService.create(staffDO);
		
		if(result.isSuccess()) {
			Integer id = (Integer) result.getModel(ResultSupport.FIFTH_MODEL_KEY);
			if(id!=null){
				//保存家政人员的证件信息
				String cidsid=request.getParameter("cidsid");
				certificoreService.createCertificore(id, cidsid, "身份证", author);
				
				String huzhaoid=request.getParameter("huzhaoid");
				certificoreService.createCertificore(id, huzhaoid, "护照", author);
				
				String jiankangid=request.getParameter("jiankangid");
				certificoreService.createCertificore(id, jiankangid, "健康证", author);
				
				String muyingid=request.getParameter("muyingid");
				certificoreService.createCertificore(id, muyingid, "母婴护理证", author);
				
				String yuyingid=request.getParameter("yuyingid");
				certificoreService.createCertificore(id, yuyingid, "育婴师证", author);
				
				String zaojiaoid=request.getParameter("zaojiaoid");
				certificoreService.createCertificore(id, zaojiaoid, "早教证", author);
				
				String yingyangid=request.getParameter("yingyangid");
				certificoreService.createCertificore(id, yingyangid, "营养师证", author);
				
				String cuiruid=request.getParameter("cuiruid");
				certificoreService.createCertificore(id, cuiruid, "催乳证", author);
				
				String jiashiid=request.getParameter("jiashiid");
				certificoreService.createCertificore(id, jiashiid, "驾驶证", author);
				
				String yanglaoid=request.getParameter("yanglaoid");
				certificoreService.createCertificore(id, yanglaoid, "养老护理证", author);
				
				String chushiid=request.getParameter("chushiid");
				certificoreService.createCertificore(id, chushiid, "厨师证", author);
				
				String jiazhengid=request.getParameter("jiazhengid");
				certificoreService.createCertificore(id, jiazhengid, "家政员工证", author);
				
				String huliid=request.getParameter("huliid");
				certificoreService.createCertificore(id, huliid, "护理证", author);
				
			}
			
			return new ModelAndView("redirect:/staff/queryAllList/1.html");
		} else {
			mav.setViewName("error");
		}
		return mav;
	}
	

	
	@RequestMapping(value = "/remove.json", method = RequestMethod.GET)
	public ModelAndView remove(ModelAndView mav, 
			HttpServletRequest request) {
		JsonResultDO jsonResultDO = new JsonResultSupport();
		ResultDO result =null;
		String ids=request.getParameter("ids");
		String[] strs=ids.split("-");
		for (String s : strs) {
			int id=Integer.parseInt(s);
			result = staffService.remove(id);
		}
		
		
		if(result.isSuccess()) {
			jsonResultDO.setInfo("删除提交成功");
			jsonResultDO.setStatus(JsonResultDO.JSON_SUCCESS);
			mav.addObject("JSON_DATA", jsonResultDO);
		} else {
			jsonResultDO.setInfo("删除提交失败");
			jsonResultDO.setStatus(JsonResultDO.JSON_FAILED);
			mav.addObject("JSON_DATA", "error");
		}
		return mav;
	}
	
	@RequestMapping(value = "/stop.json", method = RequestMethod.GET)
	public ModelAndView stop(ModelAndView mav, 
			HttpServletRequest request) {
		JsonResultDO jsonResultDO = new JsonResultSupport();
		ResultDO result =null;
		String ids=request.getParameter("ids");
		String flag=request.getParameter("flag");
		String[] strs=ids.split("-");
		for (String s : strs) {
			int id=Integer.parseInt(s);
			
			StaffDO staffDO = new StaffDO();
			staffDO.setId(id);
			if(flag!=null && !("".equals(flag))){
				staffDO.setStatus(Integer.parseInt(flag));
			}
			result = staffService.modifi(staffDO);
		}
		
		if(result.isSuccess()) {
			jsonResultDO.setInfo("提交成功");
			jsonResultDO.setStatus(JsonResultDO.JSON_SUCCESS);
			mav.addObject("JSON_DATA", jsonResultDO);
		} else {
			jsonResultDO.setInfo("提交失败");
			jsonResultDO.setStatus(JsonResultDO.JSON_FAILED);
			mav.addObject("JSON_DATA", "error");
		}
		return mav;
	}
	
	@RequestMapping(value = "/start/{id}.json", method = RequestMethod.GET)
	public ModelAndView start(ModelAndView mav, 
			@PathVariable(value="id") Integer id,
			HttpServletRequest request) {
		
		JsonResultDO jsonResultDO = new JsonResultSupport();
		StaffDO staffDO = new StaffDO();
		
		staffDO.setId(id);
		staffDO.setStatus(0);
		ResultDO result = staffService.modifi(staffDO);
		
		if(result.isSuccess()) {
			jsonResultDO.setInfo("提交成功");
			jsonResultDO.setStatus(JsonResultDO.JSON_SUCCESS);
			mav.addObject("JSON_DATA", jsonResultDO);
		} else {
			jsonResultDO.setInfo("提交失败");
			jsonResultDO.setStatus(JsonResultDO.JSON_FAILED);
			mav.addObject("JSON_DATA", "error");
		}
		return mav;
	}
	
	
	
	@RequestMapping(value = "/details.html", method = RequestMethod.GET)
	public ModelAndView detail(ModelAndView mav, 
			HttpServletRequest request) {
		String id=request.getParameter("id");
		ResultDO result = staffService.get(Integer.parseInt(id));
	
		if(result.isSuccess()) {
			mav.addObject("staff",  result.getModel(ResultSupport.FIRST_MODEL_KEY));
			
			//查询证件信息
			CertificoreDO certificoreDO=new CertificoreDO();
			certificoreDO.setwCeStaffId(Integer.parseInt(id));
			ResultDO  result2=certificoreService.list(certificoreDO);
			if(result2.isSuccess()){
				 List<CertificoreDO> list=(List<CertificoreDO>) result2.getModel(ResultSupport.FIRST_MODEL_KEY);
				mav.addObject("certificore",list);
			}
			
			mav.setViewName("manager2/staff/view_resume");
		} else {
			mav.setViewName("error");
		}
		return mav;
	}
	
	@RequestMapping(value = "/edit.html", method = RequestMethod.POST)
	public ModelAndView edit(ModelAndView mav,
			StaffDO staffDO,
			HttpServletRequest request) {
		
		staffDO.setModifiAuthor((String) request.getSession().getAttribute("MANAGER_NAME"));
		
		ResultDO result = staffService.modifi(staffDO);
		
		if(result.isSuccess()) {
			return new ModelAndView("redirect:/staff/queryAllList/1.html");
		} else {
			mav.setViewName("error");
		}
		return mav;
	}
	
	
	
	@RequestMapping(value = "/check/{id}.json", method = RequestMethod.GET)
	public ModelAndView check(ModelAndView mav, 
			@PathVariable(value="id") Integer id,
			HttpServletRequest request) {
		JsonResultDO jsonResultDO = new JsonResultSupport();
		StaffDO staffDO = new StaffDO();
		staffDO.setId(id);
		//状态码 0：停用 1：启用  2:待审核（如果是管理员添加不用审核）
		staffDO.setStatus(1);
		staffDO.setModifiAuthor((String) request.getSession().getAttribute("MANAGER_NAME"));
		
		ResultDO result = staffService.modifi(staffDO);
		
		if(result.isSuccess()) {
			jsonResultDO.setInfo("提交成功");
			jsonResultDO.setStatus(JsonResultDO.JSON_SUCCESS);
			mav.addObject("JSON_DATA", jsonResultDO);
		} else {
			jsonResultDO.setInfo("提交成功");
			jsonResultDO.setStatus(JsonResultDO.JSON_SUCCESS);
			mav.addObject("JSON_DATA", jsonResultDO);
		}
		return mav;
	} 
	
	@RequestMapping(value = "/list/{serviceType}/{pageNo}.html", method = RequestMethod.GET)
	public ModelAndView query(ModelAndView mav,
			@PathVariable(value="serviceType") Integer serviceType,
			@PathVariable(value="pageNo") Integer pageNo,
			HttpServletRequest request) {
		
		//Integer supplierId = (Integer) request.getSession().getAttribute("MANAGER_SUPPLIER_ID");
		StaffQuery query = new StaffQuery();
		//query.setSupplierId(supplierId);
		query.setPage(true);
		query.setPageNO(pageNo);
		query.setPageRows(10);
		//query.setServiceType(serviceType);
		
		ResultDO result = staffService.list(query);
		System.out.println(result);
		if(result.isSuccess()) {
			PageBeanUtil pageBean = new PageBeanUtil();
			long count = (Long) result.getModel(ResultSupport.SECOND_MODEL_KEY);
			pageBean.setCurrentPage(pageNo);
			pageBean.setPageSize(query.getPageRows());
			pageBean.setRecordCount(count);
			pageBean.setPageCount(count);
			pageBean.setPages(pageNo);
			pageBean.setDataList((List<Object>) result.getModel(ResultSupport.FIRST_MODEL_KEY));
			mav.addObject("PAGE_BEAN", pageBean);
			System.out.println(serviceType);
			switch(serviceType) {
			case 0: {
				mav.setViewName("manager/staff/clearList");
				break;
			}
			}
		} else {
			mav.setViewName("error");
		}
		return mav;
		
	}
	
	@RequestMapping(value = "/list/{pageNo}.html", method = RequestMethod.GET)
	public ModelAndView queryList(ModelAndView mav,
			@PathVariable(value="pageNo") Integer pageNo,
			HttpServletRequest request) {
		
		Integer supplierId = (Integer) request.getSession().getAttribute("MANAGER_SUPPLIER_ID");
		StaffQuery query = new StaffQuery();
		query.setSupplierId(supplierId);
		query.setPage(true);
		query.setPageNO(pageNo);
		query.setPageRows(10);
		query.setStatus(1);
		
		String name=request.getParameter("name");
		if(name!=null && !("".equals(name))){
			query.setStaffName(name);
		}
		
		String wSType0=request.getParameter("wSType0");
		if(wSType0!=null && !("".equals(wSType0))){
			query.setwSType0(Integer.parseInt(wSType0));
		}
		String wSType1=request.getParameter("wSType1");
		if(wSType1!=null && !("".equals(wSType1))){
			query.setwSType1(Integer.parseInt(wSType1));
		}
		String wSType2=request.getParameter("wSType2");
		if(wSType2!=null && !("".equals(wSType2))){
			query.setwSType2(Integer.parseInt(wSType2));
		}
		String wSType3=request.getParameter("wSType3");
		if(wSType3!=null && !("".equals(wSType3))){
			query.setwSType3(Integer.parseInt(wSType3));
		}
		String wSType4=request.getParameter("wSType4");
		if(wSType4!=null && !("".equals(wSType4))){
			query.setwSType4(Integer.parseInt(wSType4));
		}
		String wSType5=request.getParameter("wSType5");
		if(wSType5!=null && !("".equals(wSType5))){
			query.setwSType5(Integer.parseInt(wSType5));
		}
		String wSType6=request.getParameter("wSType6");
		if(wSType6!=null && !("".equals(wSType6))){
			query.setwSType6(Integer.parseInt(wSType6));
		}
		String wSType7=request.getParameter("wSType7");
		if(wSType7!=null && !("".equals(wSType7))){
			query.setwSType7(Integer.parseInt(wSType7));
		}
		String wSType8=request.getParameter("wSType8");
		if(wSType8!=null && !("".equals(wSType8))){
			query.setwSType8(Integer.parseInt(wSType8));
		}
		String wSType9=request.getParameter("wSType9");
		if(wSType9!=null && !("".equals(wSType9))){
			query.setwSType9(Integer.parseInt(wSType9));
		}
		
		String wSWorkerStatus=request.getParameter("wSWorkerStatus");
		if(wSWorkerStatus!=null && !("".equals(wSWorkerStatus))){
			query.setwSWorkerStatus(Integer.parseInt(wSWorkerStatus));
		}
		String status=request.getParameter("status");
		if(status!=null && !("".equals(status))){
			query.setStatus(Integer.parseInt(status));
		}
		String bigwSAge=request.getParameter("bigwSAge");
		if(bigwSAge!=null && !("".equals(bigwSAge))){
			query.setBigwSAge(Integer.parseInt(bigwSAge));
		}
		String smallwSAge=request.getParameter("smallwSAge");
		if(smallwSAge!=null && !("".equals(smallwSAge))){
			query.setSmallwSAge(Integer.parseInt(smallwSAge));
		}
		String wSEdu=request.getParameter("wSEdu");
		if(wSEdu!=null && !("".equals(wSEdu))){
			query.setwSEdu(wSEdu);
		}
		String wSNation=request.getParameter("wSNation");
		if(wSNation!=null && !("".equals(wSNation))){
			query.setwSNation(wSNation);
		}
		
		ResultDO result = staffService.list(query);
		System.out.println(result);
		if(result.isSuccess()) {
			PageBeanUtil pageBean = new PageBeanUtil();
			long count = (Long) result.getModel(ResultSupport.SECOND_MODEL_KEY);
			pageBean.setCurrentPage(pageNo);
			pageBean.setPageSize(query.getPageRows());
			pageBean.setRecordCount(count);
			pageBean.setPageCount(count);
			pageBean.setPages(pageNo);
			pageBean.setDataList((List<Object>) result.getModel(ResultSupport.FIRST_MODEL_KEY));
			mav.addObject("PAGE_BEAN", pageBean);
			mav.setViewName("manager2/staff/staff_shelves");
		} else {
			mav.setViewName("error");
		}
		return mav;
		
	}
	
	@RequestMapping(value = "/timeList/{staffId}/{status}/{pageNo}.html", method = RequestMethod.GET)
	public ModelAndView timeList(ModelAndView mav,
			@PathVariable(value="staffId") Integer staffId,
			@PathVariable(value="status") Integer status,
			@PathVariable(value="pageNo") Integer pageNo,
			HttpServletRequest request) {
		
		StaffTimeQuery query = new StaffTimeQuery();
		Integer supplierId = (Integer) request.getSession().getAttribute("MANAGER_SUPPLIER_ID");
		query.setPage(true);
		query.setPageNO(pageNo);
		query.setPageRows(10);
		if(staffId != 0) {
			query.setStaffId(staffId);
		}
		query.setSupplierId(supplierId);
		query.setStatus(status);
		ResultDO result = staffService.listStaffTime(query);
		System.out.println(result);
		if(result.isSuccess()) {
			PageBeanUtil pageBean = new PageBeanUtil();
			long count = (Long) result.getModel(ResultSupport.SECOND_MODEL_KEY);
			pageBean.setCurrentPage(pageNo);
			pageBean.setPageSize(query.getPageRows());
			pageBean.setRecordCount(count);
			pageBean.setPageCount(count);
			pageBean.setPages(pageNo);
			pageBean.setDataList((List<Object>) result.getModel(ResultSupport.FIRST_MODEL_KEY));
			mav.addObject("PAGE_BEAN", pageBean);
			if(status == 1) {
				mav.setViewName("manager/staff/timeList");
			} else {
				StaffQuery q = new StaffQuery();
				q.setSupplierId(supplierId);
				q.setwSType0(1);
				ResultDO r2 = staffService.list(q);
				mav.addObject("FEE_COUNT", result.getModel(ResultSupport.THIRD_MODEL_KEY));
				mav.addObject("STAFF_LIST", r2.getModel(ResultSupport.FIRST_MODEL_KEY));
				mav.setViewName("manager/staff/clearSettleList");
			}
		} else {
			mav.setViewName("error");
		}
		return mav;
		
	}
	
	@RequestMapping(value = "/staffList.json", method = RequestMethod.GET)
	public ModelAndView getStaffList(ModelAndView mav, 
			HttpServletRequest request) {
		Integer supplierId = (Integer) request.getSession().getAttribute("MANAGER_SUPPLIER_ID");
		StaffQuery query = new StaffQuery();
		//query.setServiceType(0);
		query.setSupplierId(supplierId);
		query.setStatus(1);
		ResultDO result = staffService.list(query);
		if(result.isSuccess()) {
			String html = "<option value=\"\">请选择</option>";
			List<StaffDO> staffList = (List<StaffDO>) result.getModel(result.FIRST_MODEL_KEY);
			for(StaffDO staff : staffList) {
				html += "<option value=\"" + staff.getId() + "\">" + staff.getwSName() + "</option>";
			}
			mav.addObject("JSON_DATA", html);
		} else {
			mav.addObject("JSON_DATA", 0);
		}
		return mav;
	}
	
	@RequestMapping(value = "/staffList/{status}/{pageNo}.html", method = RequestMethod.GET)
	public ModelAndView staffList(ModelAndView mav,
			@PathVariable(value="status") Integer status,
			@PathVariable(value="pageNo") Integer pageNo,
			HttpServletRequest request) {
		
		Integer supplierId = (Integer) request.getSession().getAttribute("MANAGER_SUPPLIER_ID");
		StaffQuery query = new StaffQuery();
		query.setSupplierId(supplierId);
		query.setStatus(status);		
		query.setPageNO(pageNo);
		query.setPageRows(10);
		query.setSupplierId(supplierId);
		query.setStatus(status);
		ResultDO result = staffService.list(query);
		if(result.isSuccess()) {
			PageBeanUtil pageBean = new PageBeanUtil();
			long count = (Long) result.getModel(ResultSupport.SECOND_MODEL_KEY);
			pageBean.setCurrentPage(pageNo);
			pageBean.setPageSize(query.getPageRows());
			pageBean.setRecordCount(count);
			pageBean.setPageCount(count);
			pageBean.setPages(pageNo);
			pageBean.setDataList((List<Object>) result.getModel(ResultSupport.FIRST_MODEL_KEY));
			mav.addObject("PAGE_BEAN", pageBean);
			mav.setViewName("manager/staff/staffList");
		} else {
			mav.setViewName("error");
		}
		return mav;
		
	}
	
	
	//人员管理查询
	@RequestMapping(value = "/queryAllList/{pageNo}.html", method = RequestMethod.GET)
	public ModelAndView queryAllList(ModelAndView mav,
			@PathVariable(value="pageNo") Integer pageNo,
			HttpServletRequest request) {
		
		
		Integer supplierId = (Integer) request.getSession().getAttribute("MANAGER_SUPPLIER_ID");
		StaffQuery query = new StaffQuery();
		query.setSupplierId(supplierId);
		query.setPage(true);
		query.setPageNO(pageNo);
		query.setPageRows(10);
		
		String name=request.getParameter("name");
		if(name!=null && !("".equals(name))){
			query.setStaffName(name);
		}
		String wSType0=request.getParameter("wSType0");
		if(wSType0!=null && !("".equals(wSType0))){
			query.setwSType0(Integer.parseInt(wSType0));
		}
		String wSType1=request.getParameter("wSType1");
		if(wSType1!=null && !("".equals(wSType1))){
			query.setwSType1(Integer.parseInt(wSType1));
		}
		String wSType2=request.getParameter("wSType2");
		if(wSType2!=null && !("".equals(wSType2))){
			query.setwSType2(Integer.parseInt(wSType2));
		}
		String wSType3=request.getParameter("wSType3");
		if(wSType3!=null && !("".equals(wSType3))){
			query.setwSType3(Integer.parseInt(wSType3));
		}
		String wSType4=request.getParameter("wSType4");
		if(wSType4!=null && !("".equals(wSType4))){
			query.setwSType4(Integer.parseInt(wSType4));
		}
		String wSType5=request.getParameter("wSType5");
		if(wSType5!=null && !("".equals(wSType5))){
			query.setwSType5(Integer.parseInt(wSType5));
		}
		String wSType6=request.getParameter("wSType6");
		if(wSType6!=null && !("".equals(wSType6))){
			query.setwSType6(Integer.parseInt(wSType6));
		}
		String wSType7=request.getParameter("wSType7");
		if(wSType7!=null && !("".equals(wSType7))){
			query.setwSType7(Integer.parseInt(wSType7));
		}
		String wSType8=request.getParameter("wSType8");
		if(wSType8!=null && !("".equals(wSType8))){
			query.setwSType8(Integer.parseInt(wSType8));
		}
		String wSType9=request.getParameter("wSType9");
		if(wSType9!=null && !("".equals(wSType9))){
			query.setwSType9(Integer.parseInt(wSType9));
		}
		
		String wSWorkerStatus=request.getParameter("wSWorkerStatus");
		if(wSWorkerStatus!=null && !("".equals(wSWorkerStatus))){
			query.setwSWorkerStatus(Integer.parseInt(wSWorkerStatus));
		}
		String status=request.getParameter("status");
		if(status!=null && !("".equals(status))){
			query.setStatus(Integer.parseInt(status));
		}
		String bigwSAge=request.getParameter("bigwSAge");
		if(bigwSAge!=null && !("".equals(bigwSAge))){
			query.setBigwSAge(Integer.parseInt(bigwSAge));
		}
		String smallwSAge=request.getParameter("smallwSAge");
		if(smallwSAge!=null && !("".equals(smallwSAge))){
			query.setSmallwSAge(Integer.parseInt(smallwSAge));
		}
		String wSEdu=request.getParameter("wSEdu");
		if(wSEdu!=null && !("".equals(wSEdu))){
			query.setwSEdu(wSEdu);
		}
		String wSNation=request.getParameter("wSNation");
		if(wSNation!=null && !("".equals(wSNation))){
			query.setwSNation(wSNation);
		}
		
		//System.out.println(name+" *** "+wSType+" ///  "+wSWorkerStatus+" --- "+status+"  /// "+bigwSAge+" /// "+smallwSAge+"  /// "+wSEdu+"  /// "+wSNation);
		
		ResultDO result = staffService.list(query);
		if(result.isSuccess()) {
			PageBeanUtil pageBean = new PageBeanUtil();
			long count = (Long) result.getModel(ResultSupport.SECOND_MODEL_KEY);
			pageBean.setCurrentPage(pageNo);
			pageBean.setPageSize(query.getPageRows());
			pageBean.setRecordCount(count);
			pageBean.setPageCount(count);
			pageBean.setPages(pageNo);
			pageBean.setDataList((List<Object>) result.getModel(ResultSupport.FIRST_MODEL_KEY));
			mav.addObject("PAGE_BEAN", pageBean);
			mav.setViewName("manager2/staff/staff_whole");
		} else {
			mav.setViewName("error");
		}
		return mav;
		
	}
	
 }
